package com.superzqb.asus.superzqbFragment.superzqbJobShop.Enterprise;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.superzqb.asus.superzqb.R;
import com.superzqb.asus.superzqbActivity.BaseActivity;
import com.superzqb.asus.superzqbFragment.superzqbJobShop.Bean.CampusEnterpriseListBean;

public class CampusPositionInformation extends BaseActivity implements View.OnClickListener{
    private TextView title,position,salary,address,
            createTime,type,number,sex,agency,toWork,workDate,
            content,finishNumber,detailAddress,contact,phone,toCallPhone;
    private ImageView back;
    private Intent intent;
    private CampusEnterpriseListBean map;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.campus_position_information);
        initView();
        getData();
    }

    private void initView() {
        context=CampusPositionInformation.this;
        intent=getIntent();
        map= (CampusEnterpriseListBean) intent.getSerializableExtra("item");
        title=(TextView)findViewById(R.id.title);
        position=(TextView)findViewById(R.id.position);
        salary=(TextView)findViewById(R.id.salary);
        address=(TextView)findViewById(R.id.address);
        createTime=(TextView)findViewById(R.id.createTime);
        number=(TextView)findViewById(R.id.number);
        type=(TextView)findViewById(R.id.type);
        sex=(TextView)findViewById(R.id.sex);
        agency=(TextView)findViewById(R.id.agency);
        toWork=(TextView)findViewById(R.id.toWork);
        workDate=(TextView)findViewById(R.id.workDate);
        content=(TextView)findViewById(R.id.content);
        finishNumber=(TextView)findViewById(R.id.finishNumber);
        detailAddress=(TextView)findViewById(R.id.detailAddress);
        contact=(TextView)findViewById(R.id.contact);
        phone=(TextView)findViewById(R.id.phone);
        toCallPhone=(TextView)findViewById(R.id.toCallPhone);
        title.setText("职位信息");
        back=(ImageView)findViewById(R.id.back);
        back.setOnClickListener(this);
        toCallPhone.setOnClickListener(this);
    }
    public void getData() {
        position.setText(map.getPosition());
        salary.setText(map.getSalary());
        address.setText(map.getAddress());
        createTime.setText(map.getCreatetime());
        type.setText(map.getType());
        number.setText(Integer.valueOf(map.getNumber())+"");
        sex.setText(map.getSex());
        agency.setText(map.getAgency());
        toWork.setText(map.getWork_per());
        workDate.setText(map.getWork_date());
        content.setText(map.getContent());
        finishNumber.setText(Integer.valueOf(map.getFinish_number())+"人");
        detailAddress.setText(map.getDetail_address());
        contact.setText(map.getContacts());
        phone.setText(map.getPhone());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.back:
                finish();break;
            case R.id.toCallPhone:
                showCallPhoneDialog();
                break;
            default:break;
        }
    }

    private void showCallPhoneDialog() {
        AlertDialog.Builder dialog=new AlertDialog.Builder(context);
        dialog.setMessage("是否拨打"+map.getPhone()+"?");
        dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:" + map.getPhone()));
                context.startActivity(intent);
            }
        });
        dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                //TODO
            }
        });
        dialog.show();
    }


}
